<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <title>更改密码</title>
    <link rel="stylesheet" href="__CSS__/login_register.css">
</head>
<body style="margin: 0;padding: 0;background-color: #f3f3f3;">
<div class="topbar-between gradient-color horizontal-view">
    <div class="topbar-back" onclick="location.href='/Wx/Login/userInfo'">
        <div class="topbar-back-icon"></div>
    </div>
    <div class="topbar-title">更改密码</div>
    <div style="width: 2.5rem;"></div>
</div>

<div class="horizontal-view binding-input-wrap">
    <div  class="text-content">原密码：</div>
    <input id="oldpwd" class="binding-input" type="password"  name="oldpwd"  placeholder="请输入原密码"/>
</div>

<div class="horizontal-view binding-input-wrap">
    <div  class="text-content">新密码：</div>
    <input id="newpwd" class="binding-input" type="password"  name="newpwd"  placeholder="请输入6位以上新密码"/>
</div>
<div class="horizontal-view binding-input-wrap" style="margin-top: 1px">
    <div  class="text-content">重复新密码：</div>
    <input  id="rnewpwd" class="binding-input" type="password"  name="rnewpwd" placeholder="请再次确认新密码"/>
</div>
<a href="{:U('Login/resetLoginPwd')}"><div class="forget-btn text-blue">忘记当前密码？</div></a>
<div class="button-simple button-simple-color" onclick="save()">确认</div>
<input type="hidden" id="isrepeat" value="0"/>
<input type="hidden" id="sendStatus" value="0"/>
<script type="text/javascript" src="__JS__/jquery2.1.1.min.js"></script>
<script src="__JS__/layer.min.js"></script>
<script type="text/javascript">
function save() {
    if($('#isrepeat').val()==1){
        layer.msg('请不要重复提交');
        return;
    }
    var url = "/Wx/Login/changeLoginPwdHandle"
    var newpwd=$.trim($('#newpwd').val());
    var rewpwd=$.trim($('#rnewpwd').val());
    var oldpwd=$.trim($('#oldpwd').val());
    var re = /^\d+$/;
//    if(!re.test(newpwd)||!re.test(oldpwd)){
//        layer.msg('密码只能是数字');
//        return;
//    }

    if(rewpwd==''||newpwd==''||oldpwd==''||newpwd.length<6||rewpwd.length<6||oldpwd.length<6){
        layer.msg('密码长度不对(大于6位)');
        return;
    }
    if(rewpwd!=newpwd){
        layer.msg('重复密码不正确');
        return;
    }
    $('#isrepeat').val(1);
    $.ajax({
        type : "POST",
        url : url,
        data : {
            oldpwd:oldpwd,
            newpwd:newpwd,
        },
        dataType : "json",
        success : function(data) {
            if(data.status==-3){
                $('#isrepeat').val(0);
                layer.msg('请登录后再尝试');
                return;
            }else if(data.status==0){
                layer.msg('密码设置成功');
                setTimeout(function(){
                    location.href="/Wx/Login/userInfo";
                },2000);
                return;
            }else if(data.status==-2){
                $('#isrepeat').val(0);
                layer.msg('旧密码不正确');
                return;
            }else{
                $('#isrepeat').val(0);
                layer.msg('密码修改失败');
                return;
            }
        }
    });
}
</script>
</body>
</html>